package com.wugenqiang.project.system.controller;




import com.wugenqiang.project.system.pojo.User;
import com.wugenqiang.utils.MapCache;
import com.wugenqiang.utils.TaleUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * @Classname BaseController
 * @Description BaseController
 * @Date 2019/1/24 10:34
 * @Created by WuGenQiang//fighting!!
 */
public abstract class BaseController {

    protected MapCache cache = MapCache.single();

    public BaseController title(HttpServletRequest request, String title) {
        request.setAttribute("title", title);
        return this;
    }

    public BaseController keywords(HttpServletRequest request, String keywords) {
        request.setAttribute("keywords", keywords);
        return this;
    }

    /**
     * 获取请求绑定的登录对象
     * @param request
     * @return
     */
    public User user(HttpServletRequest request) {
        return TaleUtils.getLoginUser(request);
    }

    public Integer getUid(HttpServletRequest request){
        return this.user(request).getId();
    }

    public String render_404() {
        return "error/404";
    }

}
